import { Component, OnInit } from '@angular/core';
import { ComponentBasic } from 'src/app/app.component';
import { OrderService } from 'src/app/service/order.service';
import { RoleRight } from 'src/kalend';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-uerwinhistory',
  templateUrl: './uerwinhistory.component.html',
  styleUrls: ['./uerwinhistory.component.scss'],
  providers: [OrderService]
})
export class UerwinhistoryComponent extends ComponentBasic implements OnInit {
  userid: any = RoleRight.getStorage()._id;
  loading = true;
  pageIndex = 1;
  pageSize = 15;
  total = 1;
  dataSet = [];
  paystatus: any;
  sdate: any;
  edate: any;
  footTotal: any;
  constructor(private service: OrderService, private ar: ActivatedRoute) {
    super();
    super.setLayout(true, true);
    if (this.ar.snapshot.params && this.ar.snapshot.params.id) {
      this.userid = this.ar.snapshot.params.id;
    }
  }

  ngOnInit() {
    this.searchData();
  }
  searchData(reset: boolean = false): void {
    this.loading = true;
    this.service.getuserwinhis({
      offset: this.pageIndex,
      limit: this.pageSize,
      uid: this.userid,
      starttime: this.sdate,
      endtime: this.edate
    }).then((res) => {
      this.loading = false;
      this.total = res.total;
      this.dataSet = res.rows;
      this.footTotal = res.footTotal;
    });
  }

}
